package cn.net.isir.controller.manager;

import cn.net.isir.common.ResultObject;
import cn.net.isir.entity.Menu;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

/**
 * @author liuxubo
 * @filename MenuController.java
 * @package cn.net.isir.controller.manager
 * @email lxb@isir.net.cn
 * @date 2018/11/26
 * @comment
 * @since 1.8
 */
@RestController
@RequestMapping("/menu")
public class MenuController {

    @RequestMapping(method = RequestMethod.GET, value = "/")
    public ResultObject menu(HttpServletRequest request, HttpServletResponse response) {
//        User user = TokenManager.getToken();
        // SELECT *
        //         FROM t_menu m
        // LEFT JOIN t_permission_menu pm ON pm.menuId = m.id
        // LEFT JOIN t_role_permission rp ON rp.permissionId = pm.permissionId
        // LEFT JOIN t_user_role ur ON ur.roleId = rp.roleId
        // WHERE ur.userId = '';
        List<Menu> menuList = new ArrayList<>();
        Menu shop = new Menu();
        shop.setId("1");
        shop.setName("店铺管理");
        shop.setPath("/shop");
        shop.setPid(0);
        menuList.add(shop);

        Menu my = new Menu();
        my.setId("11");
        my.setName("我的店铺");
        my.setPath(shop.getPath() + "/my");
        my.setPid(Integer.valueOf(shop.getId()));
        menuList.add(my);

        Menu pay = new Menu();
        pay.setId("12");
        pay.setName("第三方支付");
        pay.setPath(shop.getPath() + "/pay");
        pay.setPid(Integer.valueOf(shop.getId()));
        menuList.add(pay);

        Menu table = new Menu();
        table.setId("13");
        table.setName("台号设置");
        table.setPath(shop.getPath() + "/table");
        table.setPid(Integer.valueOf(shop.getId()));
        menuList.add(table);


        Menu menu = new Menu();
        menu.setId("2");
        menu.setName("菜单管理");
        menu.setPath("/menu");
        menu.setPid(0);
        menuList.add(menu);

        Menu category = new Menu();
        category.setId("21");
        category.setName("菜品种类管理");
        category.setPath(menu.getPath() + "/category");
        category.setPid(Integer.valueOf(menu.getId()));
        menuList.add(category);

        Menu goods = new Menu();
        goods.setId("22");
        goods.setName("菜品管理");
        goods.setPath(menu.getPath() + "/goods");
        goods.setPid(Integer.valueOf(menu.getId()));
        menuList.add(goods);


        Menu order = new Menu();
        order.setId("3");
        order.setName("订单管理");
        order.setPath("/order");
        order.setPid(0);
        menuList.add(order);

//        Menu orderManage = new Menu();
//        orderManage.setId("31");
//        orderManage.setName("订单管理");
//        orderManage.setPath(order.getPath() + "/manage");
//        orderManage.setPid(Integer.valueOf(order.getId()));
//        menuList.add(orderManage);

        Menu finance = new Menu();
        finance.setId("4");
        finance.setName("财务管理");
        finance.setPath("/finance");
        finance.setPid(0);
        menuList.add(finance);

//        Menu statistics = new Menu();
//        statistics.setId("41");
//        statistics.setName("店铺管理");
//        statistics.setPath(finance.getPath() + "/statistics");
//        statistics.setPid(Integer.valueOf(finance.getId()));
//        menuList.add(statistics);

        ResultObject resultObject = new ResultObject();
        resultObject.setResult(200);
        resultObject.setMessage("success");
        resultObject.setObject(menuList);
        return resultObject;
    }
}
